package learn.java.basic;

import com.aliyun.ons20190214.models.OnsTopicCreateRequest;
import com.aliyun.teaopenapi.models.Config;

/**
 * @author suzheng
 * @date 2021-06-25
 **/
public class GenerateTopic {
    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.ons20190214.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "ons.cn-qingdao.aliyuncs.com";
        return new com.aliyun.ons20190214.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.ons20190214.Client client = createClient("accessKeyId", "accessKeySecret");
        OnsTopicCreateRequest onsTopicCreateRequest = new OnsTopicCreateRequest()
                .setTopic("dfgdf")
                .setMessageType(0);
        // 复制代码运行请自行打印 API 的返回值
        client.onsTopicCreate(onsTopicCreateRequest);
    }
}
